namespace Byond.Vst.GlobalKeyLogger
{
	public class KeyboardDispatcher
	{
		public KeyboardDispatcher()
		{
			_keyboardListener = new KeyboardListener();
			_keyboardListener.KeyDown += _keyboardListener_KeyDown;
			_keyboardListener.KeyUp += _keyboardListener_KeyUp;
		}

		private readonly KeyboardListener _keyboardListener;
		//private readonly List<KeyEvent> _events = new List<KeyEvent>();

		//public bool IsEnabled { get; set; }

		public RawKeyEventArgs LastKeyDownEvent { get; private set; }
		public RawKeyEventArgs LastKeyUpEvent { get; private set; }

		//public IEnumerable<KeyEvent> PopEvents()
		//{
		//    lock (_events)
		//    {
		//        var events = _events.ToList();
		//        _events.Clear();
		//        return events;
		//    }
		//}

		void _keyboardListener_KeyDown(object sender, RawKeyEventArgs args)
		{
			LastKeyDownEvent = args;
			//if (!IsEnabled)
			//    return;
			//lock (_events)
			//    _events.Add(new KeyDownEvent(args));
		}

		void _keyboardListener_KeyUp(object sender, RawKeyEventArgs args)
		{
			LastKeyUpEvent = args;
			//if (!IsEnabled)
			//    return;
			//lock (_events)
			//    _events.Add(new KeyUpEvent(args));
		}
	}

	//public abstract class KeyEvent
	//{
	//    protected KeyEvent(RawKeyEventArgs eventData)
	//    {
	//        FocusedElement = Keyboard.FocusedElement;
	//        EventData = eventData;
	//    }

	//    public RawKeyEventArgs EventData { get; private set; }
	//    public IInputElement FocusedElement { get; private set; }
	//}

	//class KeyUpEvent : KeyEvent
	//{
	//    public KeyUpEvent(RawKeyEventArgs eventData)
	//        : base(eventData)
	//    {
	//    }
	//}

	//class KeyDownEvent : KeyEvent
	//{
	//    public KeyDownEvent(RawKeyEventArgs eventData)
	//        : base(eventData)
	//    {
	//    }
	//}
}
